<!DOCTYPE HTML>
<html lang="en" >
    
    <head>
        
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>自述 | Redux 中文文档 Join the chat at https://gitter.im/camsong/redux-in-chinese</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="&lt;img src=&#39;https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67&#39; height=&#39;60&#39;&gt;">
        <meta name="generator" content="GitBook 2.3.3">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="gitbook/style.css">
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-edit-link/plugin.css">
        
    
        
        <link rel="stylesheet" href="gitbook/plugins/gitbook-plugin-prism/prism.css">
        
    
    

        
    
    
    <link rel="next" href="./docs/introduction/index.html" />
    
    

        
    </head>
    <body>
        
        
    <div class="book" data-level="0" data-basepath="." data-revision="Thu Mar 16 2017 23:41:56 GMT+0800 (CST)">
    

<div class="book-summary">
    <div class="book-search">
        <input type="text" placeholder="Type to search" class="form-control" />
    </div>
    <ul class="summary">
        
        
        
        

        

        
    
        <li class="chapter active" data-level="0" data-path="index.html">
            
                
                    <a href="./index.html">
                
                        <i class="fa fa-check"></i>
                        
                        自述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="docs/introduction/index.html">
            
                
                    <a href="./docs/introduction/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        介绍
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="1.1" data-path="docs/introduction/Motivation.html">
            
                
                    <a href="./docs/introduction/Motivation.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        动机
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="docs/introduction/CoreConcepts.html">
            
                
                    <a href="./docs/introduction/CoreConcepts.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        核心概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="docs/introduction/ThreePrinciples.html">
            
                
                    <a href="./docs/introduction/ThreePrinciples.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        三大原则
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="docs/introduction/PriorArt.html">
            
                
                    <a href="./docs/introduction/PriorArt.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        先前技术
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.5" data-path="docs/introduction/Ecosystem.html">
            
                
                    <a href="./docs/introduction/Ecosystem.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.5.</b>
                        
                        生态系统
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.6" data-path="docs/introduction/Examples.html">
            
                
                    <a href="./docs/introduction/Examples.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.6.</b>
                        
                        示例
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="docs/basics/index.html">
            
                
                    <a href="./docs/basics/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        基础
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="docs/basics/Actions.html">
            
                
                    <a href="./docs/basics/Actions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        Action
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="docs/basics/Reducers.html">
            
                
                    <a href="./docs/basics/Reducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        Reducer
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="docs/basics/Store.html">
            
                
                    <a href="./docs/basics/Store.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        Store
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="docs/basics/DataFlow.html">
            
                
                    <a href="./docs/basics/DataFlow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        数据流
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="docs/basics/UsageWithReact.html">
            
                
                    <a href="./docs/basics/UsageWithReact.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        搭配 React
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.6" data-path="docs/basics/ExampleTodoList.html">
            
                
                    <a href="./docs/basics/ExampleTodoList.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.6.</b>
                        
                        示例：Todo List
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="docs/advanced/index.html">
            
                
                    <a href="./docs/advanced/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        高级
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="docs/advanced/AsyncActions.html">
            
                
                    <a href="./docs/advanced/AsyncActions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        异步 Action
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="docs/advanced/AsyncFlow.html">
            
                
                    <a href="./docs/advanced/AsyncFlow.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        异步数据流
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="docs/advanced/Middleware.html">
            
                
                    <a href="./docs/advanced/Middleware.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        Middleware
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.4" data-path="docs/advanced/UsageWithReactRouter.html">
            
                
                    <a href="./docs/advanced/UsageWithReactRouter.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.4.</b>
                        
                        搭配 React Router
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.5" data-path="docs/advanced/ExampleRedditAPI.html">
            
                
                    <a href="./docs/advanced/ExampleRedditAPI.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.5.</b>
                        
                        示例：Reddit API
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.6" data-path="docs/advanced/NextSteps.html">
            
                
                    <a href="./docs/advanced/NextSteps.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.6.</b>
                        
                        下一步
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="docs/recipes/index.html">
            
                
                    <a href="./docs/recipes/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        技巧
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="docs/recipes/MigratingToRedux.html">
            
                
                    <a href="./docs/recipes/MigratingToRedux.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        迁移到 Redux
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="docs/recipes/UsingObjectSpreadOperator.html">
            
                
                    <a href="./docs/recipes/UsingObjectSpreadOperator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        使用对象展开运算符
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="docs/recipes/ReducingBoilerplate.html">
            
                
                    <a href="./docs/recipes/ReducingBoilerplate.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        减少样板代码
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="docs/recipes/ServerRendering.html">
            
                
                    <a href="./docs/recipes/ServerRendering.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        服务端渲染
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="docs/recipes/WritingTests.html">
            
                
                    <a href="./docs/recipes/WritingTests.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        编写测试
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.6" data-path="docs/recipes/ComputingDerivedData.html">
            
                
                    <a href="./docs/recipes/ComputingDerivedData.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.6.</b>
                        
                        计算衍生数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.7" data-path="docs/recipes/ImplementingUndoHistory.html">
            
                
                    <a href="./docs/recipes/ImplementingUndoHistory.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.7.</b>
                        
                        实现撤销重做
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.8" data-path="docs/recipes/IsolatingSubapps.html">
            
                
                    <a href="./docs/recipes/IsolatingSubapps.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.8.</b>
                        
                        子应用隔离
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9" data-path="docs/recipes/StructuringReducers.html">
            
                
                    <a href="./docs/recipes/StructuringReducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.</b>
                        
                        组织 Reducer
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.9.1" data-path="docs/recipes/reducers/PrerequisiteConcepts.html">
            
                
                    <a href="./docs/recipes/reducers/PrerequisiteConcepts.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.1.</b>
                        
                        Reducer 基础概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.2" data-path="docs/recipes/reducers/BasicReducerStructure.html">
            
                
                    <a href="./docs/recipes/reducers/BasicReducerStructure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.2.</b>
                        
                        Reducer 基础结构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.3" data-path="docs/recipes/reducers/SplittingReducerLogic.html">
            
                
                    <a href="./docs/recipes/reducers/SplittingReducerLogic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.3.</b>
                        
                        Reducer 逻辑拆分
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.4" data-path="docs/recipes/reducers/RefactoringReducersExample.html">
            
                
                    <a href="./docs/recipes/reducers/RefactoringReducersExample.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.4.</b>
                        
                        Reducer 重构示例
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.5" data-path="docs/recipes/reducers/UsingCombineReducers.html">
            
                
                    <a href="./docs/recipes/reducers/UsingCombineReducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.5.</b>
                        
                        `combineReducers` 用法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.6" data-path="docs/recipes/reducers/BeyondCombineReducers.html">
            
                
                    <a href="./docs/recipes/reducers/BeyondCombineReducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.6.</b>
                        
                        `combineReducers` 进阶
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.7" data-path="docs/recipes/reducers/NormalizingStateShape.html">
            
                
                    <a href="./docs/recipes/reducers/NormalizingStateShape.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.7.</b>
                        
                        State 范式化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.8" data-path="docs/recipes/reducers/UpdatingNormalizedData.html">
            
                
                    <a href="./docs/recipes/reducers/UpdatingNormalizedData.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.8.</b>
                        
                        管理范式化数据
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.9" data-path="docs/recipes/reducers/ReusingReducerLogic.html">
            
                
                    <a href="./docs/recipes/reducers/ReusingReducerLogic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.9.</b>
                        
                        Reducer 逻辑复用
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.10" data-path="docs/recipes/reducers/ImmutableUpdatePatterns.html">
            
                
                    <a href="./docs/recipes/reducers/ImmutableUpdatePatterns.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.10.</b>
                        
                        不可变更新模式
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.9.11" data-path="docs/recipes/reducers/InitializingState.html">
            
                
                    <a href="./docs/recipes/reducers/InitializingState.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.9.11.</b>
                        
                        初始化 State
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="docs/FAQ.html">
            
                
                    <a href="./docs/FAQ.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        常见问题
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="docs/faq/General.html">
            
                
                    <a href="./docs/faq/General.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        综合
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="docs/faq/Reducers.html">
            
                
                    <a href="./docs/faq/Reducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        Reducer
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="docs/faq/OrganizingState.html">
            
                
                    <a href="./docs/faq/OrganizingState.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        组织 State
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="docs/faq/StoreSetup.html">
            
                
                    <a href="./docs/faq/StoreSetup.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        创建 Store
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="docs/faq/Actions.html">
            
                
                    <a href="./docs/faq/Actions.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        Action
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="docs/faq/CodeStructure.html">
            
                
                    <a href="./docs/faq/CodeStructure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        代码结构
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="docs/faq/Performance.html">
            
                
                    <a href="./docs/faq/Performance.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        性能
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="docs/faq/ReactRedux.html">
            
                
                    <a href="./docs/faq/ReactRedux.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        React Redux
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="docs/faq/Miscellaneous.html">
            
                
                    <a href="./docs/faq/Miscellaneous.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        其它
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="docs/Troubleshooting.html">
            
                
                    <a href="./docs/Troubleshooting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        排错
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7" data-path="docs/Glossary.html">
            
                
                    <a href="./docs/Glossary.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        词汇表
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8" data-path="docs/api/index.html">
            
                
                    <a href="./docs/api/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        API 文档
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="docs/api/createStore.html">
            
                
                    <a href="./docs/api/createStore.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        createStore
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="docs/api/Store.html">
            
                
                    <a href="./docs/api/Store.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        Store
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="docs/api/combineReducers.html">
            
                
                    <a href="./docs/api/combineReducers.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        combineReducers
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="docs/api/applyMiddleware.html">
            
                
                    <a href="./docs/api/applyMiddleware.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        applyMiddleware
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="docs/api/bindActionCreators.html">
            
                
                    <a href="./docs/api/bindActionCreators.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        bindActionCreators
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="docs/api/compose.html">
            
                
                    <a href="./docs/api/compose.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        compose
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="9" data-path="docs/react-redux/index.html">
            
                
                    <a href="./docs/react-redux/index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.</b>
                        
                        react-redux 文档
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="9.1" data-path="docs/react-redux/api.html">
            
                
                    <a href="./docs/react-redux/api.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.1.</b>
                        
                        API
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="9.2" data-path="docs/react-redux/troubleshooting.html">
            
                
                    <a href="./docs/react-redux/troubleshooting.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>9.2.</b>
                        
                        排错
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="10" >
            
                
                    <a target="_blank" href="https:/github.com/react-guide/redux-tutorial-cn">
                
                        <i class="fa fa-check"></i>
                        
                            <b>10.</b>
                        
                        redux-tutorial
                    </a>
            
            
        </li>
    


        
        <li class="divider"></li>
        <li>
            <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                Published with GitBook
            </a>
        </li>
        
    </ul>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header">
    <!-- Actions Left -->
    <a href="#" class="btn pull-left toggle-summary" aria-label="Table of Contents"><i class="fa fa-align-justify"></i></a>
    <a href="#" class="btn pull-left toggle-search" aria-label="Search"><i class="fa fa-search"></i></a>
    
    <div id="font-settings-wrapper" class="dropdown pull-left">
        <a href="#" class="btn toggle-dropdown" aria-label="Font Settings"><i class="fa fa-font"></i>
        </a>
        <div class="dropdown-menu font-settings">
    <div class="dropdown-caret">
        <span class="caret-outer"></span>
        <span class="caret-inner"></span>
    </div>

    <div class="buttons">
        <button type="button" id="reduce-font-size" class="button size-2">A</button>
        <button type="button" id="enlarge-font-size" class="button size-2">A</button>
    </div>

    <div class="buttons font-family-list">
        <button type="button" data-font="0" class="button">Serif</button>
        <button type="button" data-font="1" class="button">Sans</button>
    </div>

    <div class="buttons color-theme-list">
        <button type="button" id="color-theme-preview-0" class="button size-3" data-theme="0">White</button>
        <button type="button" id="color-theme-preview-1" class="button size-3" data-theme="1">Sepia</button>
        <button type="button" id="color-theme-preview-2" class="button size-3" data-theme="2">Night</button>
    </div>
</div>

    </div>

    <!-- Actions Right -->
    
    <div class="dropdown pull-right">
        <a href="#" class="btn toggle-dropdown" aria-label="Share"><i class="fa fa-share-alt"></i>
        </a>
        <div class="dropdown-menu font-settings dropdown-left">
            <div class="dropdown-caret">
                <span class="caret-outer"></span>
                <span class="caret-inner"></span>
            </div>
            <div class="buttons">
                <button type="button" data-sharing="twitter" class="button">
                    Share on Twitter
                </button>
                <button type="button" data-sharing="google-plus" class="button">
                    Share on Google
                </button>
                <button type="button" data-sharing="facebook" class="button">
                    Share on Facebook
                </button>
                <button type="button" data-sharing="weibo" class="button">
                    Share on Weibo
                </button>
                <button type="button" data-sharing="instapaper" class="button">
                    Share on Instapaper
                </button>
            </div>
        </div>
    </div>
    

    
    <a href="#" target="_blank" class="btn pull-right google-plus-sharing-link sharing-link" data-sharing="google-plus" aria-label="Google"><i class="fa fa-google-plus"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right facebook-sharing-link sharing-link" data-sharing="facebook" aria-label="Facebook"><i class="fa fa-facebook"></i></a>
    
    
    <a href="#" target="_blank" class="btn pull-right twitter-sharing-link sharing-link" data-sharing="twitter" aria-label="Twitter"><i class="fa fa-twitter"></i></a>
    
    
    


    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="./" >Redux 中文文档 Join the chat at https://gitter.im/camsong/redux-in-chinese</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <a id="edit-link" href="https://github.com/camsong/redux-in-chinese/tree/master/README.md" class="btn fa fa-edit pull-left">&#xA0;&#xA0;&#x5F00;&#x59CB;&#x7EA0;&#x9519;</a><h1 id="-redux-%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3-http-github-com-camsong-redux-in-chinese-join-the-chat-at-https-gitter-im-camsong-redux-in-chinese-https-badges-gitter-im-join-20chat-svg-https-gitter-im-camsong-redux-in-chinese-utm-source-badge-utm-medium-badge-utm-campaign-pr-badge-utm-content-badge"><a href="http://github.com/camsong/redux-in-chinese" target="_blank">Redux &#x4E2D;&#x6587;&#x6587;&#x6863;</a> <a href="https://gitter.im/camsong/redux-in-chinese?utm_source=badge&amp;utm_medium=badge&amp;utm_campaign=pr-badge&amp;utm_content=badge" target="_blank"><img src="https://badges.gitter.im/Join%20Chat.svg" alt="Join the chat at https://gitter.im/camsong/redux-in-chinese"></a></h1>
<p><img src="https://camo.githubusercontent.com/f28b5bc7822f1b7bb28a96d8d09e7d79169248fc/687474703a2f2f692e696d6775722e636f6d2f4a65567164514d2e706e67" height="60"></p>
<blockquote>
<p>&#x5728;&#x7EBF; Gitbook &#x5730;&#x5740;&#xFF1A;<a href="http://cn.redux.js.org/" target="_blank">http://cn.redux.js.org/</a><br>&#x82F1;&#x6587;&#x539F;&#x7248;&#xFF1A;<a href="http://redux.js.org/" target="_blank">http://redux.js.org/</a><br>&#x5B66;&#x4E86;&#x8FD9;&#x4E2A;&#x8FD8;&#x4E0D;&#x5C3D;&#x5174;&#xFF1F;&#x63A8;&#x8350;&#x6781;&#x7CBE;&#x7B80;&#x7684; <a href="https://github.com/react-guide/redux-tutorial-cn#redux-tutorial" target="_blank">Redux Tutorial &#x6559;&#x7A0B;</a><br>React &#x6838;&#x5FC3;&#x5F00;&#x53D1;&#x8005;&#x5199;&#x7684; <a href="https://github.com/react-guide/react-basic" target="_blank">React &#x8BBE;&#x8BA1;&#x601D;&#x60F3;</a></p>
<p>:arrow_down: &#x79BB;&#x7EBF;&#x4E0B;&#x8F7D;&#xFF1A;<a href="https://github.com/camsong/redux-in-chinese/raw/master/offline/redux-in-chinese.pdf" target="_blank">pdf &#x683C;&#x5F0F;</a>&#xFF0C;<a href="https://github.com/camsong/redux-in-chinese/raw/master/offline/redux-in-chinese.epub" target="_blank">epub &#x683C;&#x5F0F;</a>&#xFF0C;<a href="https://github.com/camsong/redux-in-chinese/raw/master/offline/redux-in-chinese.mobi" target="_blank">mobi &#x683C;&#x5F0F;</a></p>
</blockquote>
<p>Redux &#x662F; JavaScript &#x72B6;&#x6001;&#x5BB9;&#x5668;&#xFF0C;&#x63D0;&#x4F9B;&#x53EF;&#x9884;&#x6D4B;&#x5316;&#x7684;&#x72B6;&#x6001;&#x7BA1;&#x7406;&#x3002;  </p>
<p>&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x6784;&#x5EFA;&#x4E00;&#x81F4;&#x5316;&#x7684;&#x5E94;&#x7528;&#xFF0C;&#x8FD0;&#x884C;&#x4E8E;&#x4E0D;&#x540C;&#x7684;&#x73AF;&#x5883;&#xFF08;&#x5BA2;&#x6237;&#x7AEF;&#x3001;&#x670D;&#x52A1;&#x5668;&#x3001;&#x539F;&#x751F;&#x5E94;&#x7528;&#xFF09;&#xFF0C;&#x5E76;&#x4E14;&#x6613;&#x4E8E;&#x6D4B;&#x8BD5;&#x3002;&#x4E0D;&#x4EC5;&#x4E8E;&#x6B64;&#xFF0C;&#x5B83;&#x8FD8;&#x63D0;&#x4F9B;
&#x8D85;&#x723D;&#x7684;&#x5F00;&#x53D1;&#x4F53;&#x9A8C;&#xFF0C;&#x6BD4;&#x5982;&#x6709;&#x4E00;&#x4E2A;<a href="https://github.com/gaearon/redux-devtools" target="_blank">&#x65F6;&#x95F4;&#x65C5;&#x884C;&#x8C03;&#x8BD5;&#x5668;&#x53EF;&#x4EE5;&#x7F16;&#x8F91;&#x540E;&#x5B9E;&#x65F6;&#x9884;&#x89C8;</a>&#x3002;</p>
<p>Redux &#x9664;&#x4E86;&#x548C; <a href="https://facebook.github.io/react/" target="_blank">React</a> &#x4E00;&#x8D77;&#x7528;&#x5916;&#xFF0C;&#x8FD8;&#x652F;&#x6301;&#x5176;&#x5B83;&#x754C;&#x9762;&#x5E93;&#x3002;<br>&#x5B83;&#x4F53;&#x5C0F;&#x7CBE;&#x608D;&#xFF08;&#x53EA;&#x6709;2kB&#xFF0C;&#x5305;&#x62EC;&#x4F9D;&#x8D56;&#xFF09;&#x3002;</p>
<h3 id="%E8%AF%84%E4%BB%B7">&#x8BC4;&#x4EF7;</h3>
<blockquote>
<p><a href="https://twitter.com/jingc/status/616608251463909376" target="_blank">&#x201C;Love what you&#x2019;re doing with Redux&#x201D;</a><br>Jing Chen&#xFF0C;Flux &#x4F5C;&#x8005;</p>
<p><a href="https://twitter.com/fisherwebdev/status/616286955693682688" target="_blank">&#x201C;I asked for comments on Redux in FB&apos;s internal JS discussion group, and it was universally praised. Really awesome work.&#x201D;</a><br>Bill Fisher&#xFF0C;Flux &#x4F5C;&#x8005;</p>
<p><a href="https://twitter.com/andrestaltz/status/616271392930201604" target="_blank">&#x201C;It&apos;s cool that you are inventing a better Flux by not doing Flux at all.&#x201D;</a><br>Andr&#xE9; Staltz&#xFF0C;Cycle &#x4F5C;&#x8005;</p>
</blockquote>
<h3 id="%E5%BC%80%E5%A7%8B%E4%B9%8B%E5%89%8D">&#x5F00;&#x59CB;&#x4E4B;&#x524D;</h3>
<blockquote>
<p>&#x4E5F;&#x63A8;&#x8350;&#x9605;&#x8BFB;&#x4F60;&#x53EF;&#x80FD;&#x5E76;&#x4E0D;&#x9700;&#x8981;Redux&#xFF1A;<br><a href="https://medium.com/@dan_abramov/you-might-not-need-redux-be46360cf367" target="_blank">&#x201C;You Might Not Need Redux&#x201D;</a></p>
</blockquote>
<h3 id="%E5%BC%80%E5%8F%91%E7%BB%8F%E5%8E%86">&#x5F00;&#x53D1;&#x7ECF;&#x5386;</h3>
<p>Redux &#x7684;&#x5F00;&#x53D1;&#x6700;&#x65E9;&#x5F00;&#x59CB;&#x4E8E;&#x6211;&#x5728;&#x51C6;&#x5907; React Europe &#x6F14;&#x8BB2;<a href="https://www.youtube.com/watch?v=xsSnOQynTHs" target="_blank">&#x70ED;&#x52A0;&#x8F7D;&#x4E0E;&#x65F6;&#x95F4;&#x65C5;&#x884C;</a>&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x5F53;&#x521D;&#x7684;&#x76EE;&#x6807;&#x662F;&#x521B;&#x5EFA;&#x4E00;&#x4E2A;&#x72B6;&#x6001;&#x7BA1;&#x7406;&#x5E93;&#xFF0C;&#x6765;&#x63D0;&#x4F9B;&#x6700;&#x7B80;&#x5316; API&#xFF0C;&#x4F46;&#x540C;&#x65F6;&#x505A;&#x5230;&#x884C;&#x4E3A;&#x7684;&#x5B8C;&#x5168;&#x53EF;&#x9884;&#x6D4B;&#xFF0C;&#x56E0;&#x6B64;&#x624D;&#x5F97;&#x4EE5;&#x5B9E;&#x73B0;&#x65E5;&#x5FD7;&#x6253;&#x5370;&#xFF0C;&#x70ED;&#x52A0;&#x8F7D;&#xFF0C;&#x65F6;&#x95F4;&#x65C5;&#x884C;&#xFF0C;&#x540C;&#x6784;&#x5E94;&#x7528;&#xFF0C;&#x5F55;&#x5236;&#x548C;&#x91CD;&#x653E;&#xFF0C;&#x800C;&#x4E0D;&#x9700;&#x8981;&#x4EFB;&#x4F55;&#x5F00;&#x53D1;&#x53C2;&#x4E0E;&#x3002;</p>
<h3 id="%E5%90%AF%E7%A4%BA">&#x542F;&#x793A;</h3>
<p>Redux &#x7531; <a href="http://facebook.github.io/flux/" target="_blank">Flux</a> &#x6F14;&#x53D8;&#x800C;&#x6765;&#xFF0C;&#x4F46;&#x53D7; <a href="http://elm-lang.org/guide/architecture" target="_blank">Elm</a> &#x7684;&#x542F;&#x53D1;&#xFF0C;&#x907F;&#x5F00;&#x4E86; Flux &#x7684;&#x590D;&#x6742;&#x6027;&#x3002;<br>&#x4E0D;&#x7BA1;&#x4F60;&#x6709;&#x6CA1;&#x6709;&#x4F7F;&#x7528;&#x8FC7;&#x5B83;&#x4EEC;&#xFF0C;&#x53EA;&#x9700;&#x51E0;&#x5206;&#x949F;&#x5C31;&#x80FD;&#x4E0A;&#x624B; Redux&#x3002;</p>
<h3 id="%E5%AE%89%E8%A3%85">&#x5B89;&#x88C5;</h3>
<p>&#x5B89;&#x88C5;&#x7A33;&#x5B9A;&#x7248;&#xFF1A;</p>
<pre><code>npm install <span class="token operator">--</span>save redux
</code></pre><p>&#x4EE5;&#x4E0A;&#x57FA;&#x4E8E;&#x4F7F;&#x7528; <a href="https://www.npmjs.com/" target="_blank">npm</a> &#x6765;&#x505A;&#x5305;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x7684;&#x60C5;&#x51B5;&#x4E0B;&#x3002;</p>
<p>&#x5426;&#x5219;&#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728; <a href="https://unpkg.com/redux/" target="_blank">unpkg &#x4E0A;&#x8BBF;&#x95EE;&#x8FD9;&#x4E9B;&#x6587;&#x4EF6;</a>&#xFF0C;&#x4E0B;&#x8F7D;&#x4E0B;&#x6765;&#xFF0C;&#x6216;&#x8005;&#x628A;&#x8BA9;&#x4F60;&#x7684;&#x5305;&#x7BA1;&#x7406;&#x5DE5;&#x5177;&#x6307;&#x5411;&#x5B83;&#x3002;</p>
<p>&#x4E00;&#x822C;&#x60C5;&#x51B5;&#x4E0B;&#x4EBA;&#x4EEC;&#x8BA4;&#x4E3A; Redux &#x5C31;&#x662F;&#x4E00;&#x4E9B; <a href="http://webpack.github.io/docs/commonjs.html" target="_blank">CommonJS</a> &#x6A21;&#x5757;&#x7684;&#x96C6;&#x5408;&#x3002;&#x8FD9;&#x4E9B;&#x6A21;&#x5757;&#x5C31;&#x662F;&#x4F60;&#x5728;&#x4F7F;&#x7528; <a href="http://webpack.github.io/" target="_blank">Webpack</a>&#x3001;<a href="http://browserify.org/" target="_blank">Browserify</a>&#x3001;&#x6216;&#x8005; Node &#x73AF;&#x5883;&#x65F6;&#x5F15;&#x5165;&#x7684;&#x3002;&#x5982;&#x679C;&#x4F60;&#x60F3;&#x8FFD;&#x6C42;&#x65F6;&#x9AE6;&#x5E76;&#x4F7F;&#x7528; <a href="http://rollupjs.org/" target="_blank">Rollup</a>&#xFF0C;&#x4E5F;&#x662F;&#x652F;&#x6301;&#x7684;&#x3002;</p>
<p>&#x4F60;&#x4E5F;&#x53EF;&#x4EE5;&#x4E0D;&#x4F7F;&#x7528;&#x6A21;&#x5757;&#x6253;&#x5305;&#x5DE5;&#x5177;&#x3002;<code>redux</code> &#x7684; npm &#x5305;&#x91CC; <a href="https://unpkg.com/redux/dist/" target="_blank"><code>dist</code> &#x76EE;&#x5F55;</a>&#x5305;&#x542B;&#x4E86;&#x9884;&#x7F16;&#x8BD1;&#x597D;&#x7684;&#x751F;&#x4EA7;&#x73AF;&#x5883;&#x548C;&#x5F00;&#x53D1;&#x73AF;&#x5883;&#x4E0B;&#x7684; <a href="https://github.com/umdjs/umd" target="_blank">UMD</a> &#x6587;&#x4EF6;&#x3002;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x4F7F;&#x7528;&#xFF0C;&#x800C;&#x4E14;&#x652F;&#x6301;&#x5927;&#x90E8;&#x5206;&#x6D41;&#x884C;&#x7684; JavaScript &#x5305;&#x52A0;&#x8F7D;&#x5668;&#x548C;&#x73AF;&#x5883;&#x3002;&#x6BD4;&#x5982;&#xFF0C;&#x4F60;&#x53EF;&#x4EE5;&#x76F4;&#x63A5;&#x5728;&#x9875;&#x9762;&#x4E0A;&#x7684; <code><span class="token operator">&lt;</span>script<span class="token operator">&gt;</span></code> &#x6807;&#x7B7E; &#x4E2D;&#x5F15;&#x5165; UMD &#x6587;&#x4EF6;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;<a href="https://github.com/reactjs/redux/pull/1181#issuecomment-167361975" target="_blank">&#x8BA9; <code>Bower</code> &#x6765;&#x5B89;&#x88C5;</a>&#x3002;UMD &#x6587;&#x4EF6;&#x53EF;&#x4EE5;&#x8BA9;&#x4F60;&#x4F7F;&#x7528; <code>window<span class="token punctuation">.</span>Redux</code> &#x5168;&#x5C40;&#x53D8;&#x91CF;&#x6765;&#x8BBF;&#x95EE; Redux&#x3002;</p>
<p>Redux &#x6E90;&#x6587;&#x4EF6;&#x7531; ES2015 &#x7F16;&#x5199;&#xFF0C;&#x4F46;&#x662F;&#x4F1A;&#x9884;&#x7F16;&#x8BD1;&#x5230; CommonJS &#x548C; UMD &#x89C4;&#x8303;&#x7684; ES5&#xFF0C;&#x6240;&#x4EE5;&#x5B83;&#x53EF;&#x4EE5;&#x652F;&#x6301; <a href="http://caniuse.com/#feat=es5" target="_blank">&#x4EFB;&#x4F55;&#x73B0;&#x4EE3;&#x6D4F;&#x89C8;&#x5668;</a>&#x3002;&#x4F60;&#x4E0D;&#x5FC5;&#x975E;&#x5F97;&#x4F7F;&#x7528; Babel &#x6216;&#x6A21;&#x5757;&#x6253;&#x5305;&#x5668;&#x6765;&#x4F7F;&#x7528; Redux&#x3002;</p>
<h4 id="%E9%99%84%E5%8A%A0%E5%8C%85">&#x9644;&#x52A0;&#x5305;</h4>
<p>&#x591A;&#x6570;&#x60C5;&#x51B5;&#x4E0B;&#xFF0C;&#x4F60;&#x8FD8;&#x9700;&#x8981;&#x4F7F;&#x7528; <a href="http://github.com/gaearon/react-redux" target="_blank">React &#x7ED1;&#x5B9A;&#x5E93;</a>&#x548C;<a href="http://github.com/gaearon/redux-devtools" target="_blank">&#x5F00;&#x53D1;&#x8005;&#x5DE5;&#x5177;</a>&#x3002;</p>
<pre><code>npm install <span class="token operator">--</span>save react<span class="token operator">-</span>redux
npm install <span class="token operator">--</span>save<span class="token operator">-</span>dev redux<span class="token operator">-</span>devtools
</code></pre><p>&#x9700;&#x8981;&#x63D0;&#x9192;&#x7684;&#x662F;&#xFF0C;&#x548C; Redux &#x4E0D;&#x540C;&#xFF0C;&#x5F88;&#x591A; Redux &#x751F;&#x6001;&#x4E0B;&#x7684;&#x5305;&#x5E76;&#x4E0D;&#x63D0;&#x4F9B; UMD &#x6587;&#x4EF6;&#xFF0C;&#x6240;&#x4EE5;&#x4E3A;&#x4E86;&#x63D0;&#x5347;&#x5F00;&#x53D1;&#x4F53;&#x9A8C;&#xFF0C;&#x6211;&#x4EEC;&#x5EFA;&#x8BAE;&#x4F7F;&#x7528;&#x50CF; <a href="http://webpack.github.io/" target="_blank">Webpack</a> &#x548C; <a href="http://browserify.org/" target="_blank">Browserify</a> &#x8FD9;&#x6837;&#x7684; CommonJS &#x6A21;&#x5757;&#x6253;&#x5305;&#x5668;&#x3002;</p>
<h3 id="%E8%A6%81%E7%82%B9">&#x8981;&#x70B9;</h3>
<p>&#x5E94;&#x7528;&#x4E2D;&#x6240;&#x6709;&#x7684; state &#x90FD;&#x4EE5;&#x4E00;&#x4E2A;&#x5BF9;&#x8C61;&#x6811;&#x7684;&#x5F62;&#x5F0F;&#x50A8;&#x5B58;&#x5728;&#x4E00;&#x4E2A;&#x5355;&#x4E00;&#x7684; <em>store</em> &#x4E2D;&#x3002;<br>&#x60DF;&#x4E00;&#x6539;&#x53D8; state &#x7684;&#x529E;&#x6CD5;&#x662F;&#x89E6;&#x53D1; <em>action</em>&#xFF0C;&#x4E00;&#x4E2A;&#x63CF;&#x8FF0;&#x53D1;&#x751F;&#x4EC0;&#x4E48;&#x7684;&#x5BF9;&#x8C61;&#x3002;<br>&#x4E3A;&#x4E86;&#x63CF;&#x8FF0; action &#x5982;&#x4F55;&#x6539;&#x53D8; state &#x6811;&#xFF0C;&#x4F60;&#x9700;&#x8981;&#x7F16;&#x5199; <em>reducers</em>&#x3002;</p>
<p>&#x5C31;&#x662F;&#x8FD9;&#x6837;&#xFF01;</p>
<pre><code class="lang-js"><span class="token keyword">import</span> <span class="token punctuation">{</span> createStore <span class="token punctuation">}</span> from <span class="token string">&apos;redux&apos;</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">/**
 * &#x8FD9;&#x662F;&#x4E00;&#x4E2A; reducer&#xFF0C;&#x5F62;&#x5F0F;&#x4E3A; (state, action) =&gt; state &#x7684;&#x7EAF;&#x51FD;&#x6570;&#x3002;
 * &#x63CF;&#x8FF0;&#x4E86; action &#x5982;&#x4F55;&#x628A; state &#x8F6C;&#x53D8;&#x6210;&#x4E0B;&#x4E00;&#x4E2A; state&#x3002;
 *
 * state &#x7684;&#x5F62;&#x5F0F;&#x53D6;&#x51B3;&#x4E8E;&#x4F60;&#xFF0C;&#x53EF;&#x4EE5;&#x662F;&#x57FA;&#x672C;&#x7C7B;&#x578B;&#x3001;&#x6570;&#x7EC4;&#x3001;&#x5BF9;&#x8C61;&#x3001;
 * &#x751A;&#x81F3;&#x662F; Immutable.js &#x751F;&#x6210;&#x7684;&#x6570;&#x636E;&#x7ED3;&#x6784;&#x3002;&#x60DF;&#x4E00;&#x7684;&#x8981;&#x70B9;&#x662F;
 * &#x5F53; state &#x53D8;&#x5316;&#x65F6;&#x9700;&#x8981;&#x8FD4;&#x56DE;&#x5168;&#x65B0;&#x7684;&#x5BF9;&#x8C61;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x4FEE;&#x6539;&#x4F20;&#x5165;&#x7684;&#x53C2;&#x6570;&#x3002;
 *
 * &#x4E0B;&#x9762;&#x4F8B;&#x5B50;&#x4F7F;&#x7528; `switch` &#x8BED;&#x53E5;&#x548C;&#x5B57;&#x7B26;&#x4E32;&#x6765;&#x505A;&#x5224;&#x65AD;&#xFF0C;&#x4F46;&#x4F60;&#x53EF;&#x4EE5;&#x5199;&#x5E2E;&#x52A9;&#x7C7B;(helper)
 * &#x6839;&#x636E;&#x4E0D;&#x540C;&#x7684;&#x7EA6;&#x5B9A;&#xFF08;&#x5982;&#x65B9;&#x6CD5;&#x6620;&#x5C04;&#xFF09;&#x6765;&#x5224;&#x65AD;&#xFF0C;&#x53EA;&#x8981;&#x9002;&#x7528;&#x4F60;&#x7684;&#x9879;&#x76EE;&#x5373;&#x53EF;&#x3002;
 */</span>
<span class="token keyword">function</span> <span class="token function">counter</span><span class="token punctuation">(</span>state <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">,</span> action<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">switch</span> <span class="token punctuation">(</span>action<span class="token punctuation">.</span>type<span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token keyword">case</span> <span class="token string">&apos;INCREMENT&apos;</span><span class="token punctuation">:</span>
    <span class="token keyword">return</span> state <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">case</span> <span class="token string">&apos;DECREMENT&apos;</span><span class="token punctuation">:</span>
    <span class="token keyword">return</span> state <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">;</span>
  <span class="token keyword">default</span><span class="token punctuation">:</span>
    <span class="token keyword">return</span> state<span class="token punctuation">;</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span>

<span class="token comment" spellcheck="true">// &#x521B;&#x5EFA; Redux store &#x6765;&#x5B58;&#x653E;&#x5E94;&#x7528;&#x7684;&#x72B6;&#x6001;&#x3002;</span>
<span class="token comment" spellcheck="true">// API &#x662F; { subscribe, dispatch, getState }&#x3002;</span>
<span class="token keyword">let</span> store <span class="token operator">=</span> <span class="token function">createStore</span><span class="token punctuation">(</span>counter<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// &#x53EF;&#x4EE5;&#x624B;&#x52A8;&#x8BA2;&#x9605;&#x66F4;&#x65B0;&#xFF0C;&#x4E5F;&#x53EF;&#x4EE5;&#x4E8B;&#x4EF6;&#x7ED1;&#x5B9A;&#x5230;&#x89C6;&#x56FE;&#x5C42;&#x3002;</span>
store<span class="token punctuation">.</span><span class="token function">subscribe</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=</span><span class="token operator">&gt;</span>
  console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>store<span class="token punctuation">.</span><span class="token function">getState</span><span class="token punctuation">(</span><span class="token punctuation">)</span><span class="token punctuation">)</span>
<span class="token punctuation">)</span><span class="token punctuation">;</span>

<span class="token comment" spellcheck="true">// &#x6539;&#x53D8;&#x5185;&#x90E8; state &#x60DF;&#x4E00;&#x65B9;&#x6CD5;&#x662F; dispatch &#x4E00;&#x4E2A; action&#x3002;</span>
<span class="token comment" spellcheck="true">// action &#x53EF;&#x4EE5;&#x88AB;&#x5E8F;&#x5217;&#x5316;&#xFF0C;&#x7528;&#x65E5;&#x8BB0;&#x8BB0;&#x5F55;&#x548C;&#x50A8;&#x5B58;&#x4E0B;&#x6765;&#xFF0C;&#x540E;&#x671F;&#x8FD8;&#x53EF;&#x4EE5;&#x4EE5;&#x56DE;&#x653E;&#x7684;&#x65B9;&#x5F0F;&#x6267;&#x884C;</span>
store<span class="token punctuation">.</span><span class="token function">dispatch</span><span class="token punctuation">(</span><span class="token punctuation">{</span> type<span class="token punctuation">:</span> <span class="token string">&apos;INCREMENT&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// 1</span>
store<span class="token punctuation">.</span><span class="token function">dispatch</span><span class="token punctuation">(</span><span class="token punctuation">{</span> type<span class="token punctuation">:</span> <span class="token string">&apos;INCREMENT&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// 2</span>
store<span class="token punctuation">.</span><span class="token function">dispatch</span><span class="token punctuation">(</span><span class="token punctuation">{</span> type<span class="token punctuation">:</span> <span class="token string">&apos;DECREMENT&apos;</span> <span class="token punctuation">}</span><span class="token punctuation">)</span><span class="token punctuation">;</span>
<span class="token comment" spellcheck="true">// 1</span>
</code></pre>
<p>&#x4F60;&#x5E94;&#x8BE5;&#x628A;&#x8981;&#x505A;&#x7684;&#x4FEE;&#x6539;&#x53D8;&#x6210;&#x4E00;&#x4E2A;&#x666E;&#x901A;&#x5BF9;&#x8C61;&#xFF0C;&#x8FD9;&#x4E2A;&#x5BF9;&#x8C61;&#x88AB;&#x53EB;&#x505A; <em>action</em>&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x76F4;&#x63A5;&#x4FEE;&#x6539; state&#x3002;&#x7136;&#x540E;&#x7F16;&#x5199;&#x4E13;&#x95E8;&#x7684;&#x51FD;&#x6570;&#x6765;&#x51B3;&#x5B9A;&#x6BCF;&#x4E2A; action &#x5982;&#x4F55;&#x6539;&#x53D8;&#x5E94;&#x7528;&#x7684; state&#xFF0C;&#x8FD9;&#x4E2A;&#x51FD;&#x6570;&#x88AB;&#x53EB;&#x505A; <em>reducer</em>&#x3002;</p>
<p>&#x5982;&#x679C;&#x4F60;&#x4EE5;&#x524D;&#x4F7F;&#x7528; Flux&#xFF0C;&#x90A3;&#x4E48;&#x4F60;&#x53EA;&#x9700;&#x8981;&#x6CE8;&#x610F;&#x4E00;&#x4E2A;&#x91CD;&#x8981;&#x7684;&#x533A;&#x522B;&#x3002;Redux &#x6CA1;&#x6709; Dispatcher &#x4E14;&#x4E0D;&#x652F;&#x6301;&#x591A;&#x4E2A; store&#x3002;&#x76F8;&#x53CD;&#xFF0C;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x5355;&#x4E00;&#x7684; store &#x548C;&#x4E00;&#x4E2A;&#x6839;&#x7EA7;&#x7684; reduce &#x51FD;&#x6570;&#xFF08;reducer&#xFF09;&#x3002;&#x968F;&#x7740;&#x5E94;&#x7528;&#x4E0D;&#x65AD;&#x53D8;&#x5927;&#xFF0C;&#x4F60;&#x5E94;&#x8BE5;&#x628A;&#x6839;&#x7EA7;&#x7684; reducer &#x62C6;&#x6210;&#x591A;&#x4E2A;&#x5C0F;&#x7684; reducers&#xFF0C;&#x5206;&#x522B;&#x72EC;&#x7ACB;&#x5730;&#x64CD;&#x4F5C; state &#x6811;&#x7684;&#x4E0D;&#x540C;&#x90E8;&#x5206;&#xFF0C;&#x800C;&#x4E0D;&#x662F;&#x6DFB;&#x52A0;&#x65B0;&#x7684; stores&#x3002;&#x8FD9;&#x5C31;&#x50CF;&#x4E00;&#x4E2A; React &#x5E94;&#x7528;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x6839;&#x7EA7;&#x7684;&#x7EC4;&#x4EF6;&#xFF0C;&#x8FD9;&#x4E2A;&#x6839;&#x7EC4;&#x4EF6;&#x53C8;&#x7531;&#x5F88;&#x591A;&#x5C0F;&#x7EC4;&#x4EF6;&#x6784;&#x6210;&#x3002;</p>
<p>&#x7528;&#x8FD9;&#x4E2A;&#x67B6;&#x6784;&#x5F00;&#x53D1;&#x8BA1;&#x6570;&#x5668;&#x6709;&#x70B9;&#x6740;&#x9E21;&#x7528;&#x725B;&#x5200;&#xFF0C;&#x4F46;&#x5B83;&#x7684;&#x7F8E;&#x5728;&#x4E8E;&#x505A;&#x590D;&#x6742;&#x5E94;&#x7528;&#x548C;&#x5E9E;&#x5927;&#x7CFB;&#x7EDF;&#x65F6;&#x4F18;&#x79C0;&#x7684;&#x6269;&#x5C55;&#x80FD;&#x529B;&#x3002;&#x7531;&#x4E8E;&#x5B83;&#x53EF;&#x4EE5;&#x7528; action &#x8FFD;&#x6EAF;&#x5E94;&#x7528;&#x7684;&#x6BCF;&#x4E00;&#x6B21;&#x4FEE;&#x6539;&#xFF0C;&#x56E0;&#x6B64;&#x624D;&#x6709;&#x5F3A;&#x5927;&#x7684;&#x5F00;&#x53D1;&#x5DE5;&#x5177;&#x3002;&#x5982;&#x5F55;&#x5236;&#x7528;&#x6237;&#x4F1A;&#x8BDD;&#x5E76;&#x56DE;&#x653E;&#x6240;&#x6709; action &#x6765;&#x91CD;&#x73B0;&#x5B83;&#x3002;</p>
<h3 id="redux-%E4%BD%9C%E8%80%85%E6%95%99%E4%BD%A0%E5%AD%A6">Redux &#x4F5C;&#x8005;&#x6559;&#x4F60;&#x5B66;</h3>
<p><a href="https://egghead.io/series/getting-started-with-redux" target="_blank">Redux &#x5165;&#x95E8;</a> &#x662F;&#x7531; Redux &#x4F5C;&#x8005; Dan Abramov &#x8BB2;&#x8FF0;&#x7684;&#x5305;&#x542B; 30 &#x4E2A;&#x89C6;&#x9891;&#x7684;&#x8BFE;&#x7A0B;&#x3002;&#x5B83;&#x6DB5;&#x76D6;&#x4E86;&#x672C;&#x6587;&#x6863;&#x7684;&#x201C;&#x57FA;&#x7840;&#x201D;&#x90E8;&#x5206;&#xFF0C;&#x540C;&#x65F6;&#x8FD8;&#x6709;&#x4E0D;&#x53EF;&#x53D8;&#xFF08;immutability&#xFF09;&#x3001;&#x6D4B;&#x8BD5;&#x3001;Redux &#x6700;&#x4F73;&#x5B9E;&#x8DF5;&#x3001;&#x642D;&#x914D; React &#x4F7F;&#x7528;&#x7684;&#x8BB2;&#x89E3;&#x3002;<strong>&#x8FD9;&#x4E2A;&#x8BFE;&#x7A0B;&#x5C06;&#x6C38;&#x4E45;&#x514D;&#x8D39;&#x3002;</strong></p>
<p>&#x8FD8;&#x7B49;&#x4EC0;&#x4E48;&#xFF1F;</p>
<h4 id="-%E5%BC%80%E5%A7%8B%E8%A7%82%E7%9C%8B-30-%E4%B8%AA%E5%85%8D%E8%B4%B9%E8%A7%86%E9%A2%91%EF%BC%81-https-egghead-io-series-getting-started-with-redux"><a href="https://egghead.io/series/getting-started-with-redux" target="_blank">&#x5F00;&#x59CB;&#x89C2;&#x770B; 30 &#x4E2A;&#x514D;&#x8D39;&#x89C6;&#x9891;&#xFF01;</a></h4>
<h3 id="%E6%96%87%E6%A1%A3">&#x6587;&#x6863;</h3>
<ul>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/introduction/index.html" target="_blank">&#x4ECB;&#x7ECD;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/basics/index.html" target="_blank">&#x57FA;&#x7840;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/advanced/index.html" target="_blank">&#x9AD8;&#x7EA7;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/recipes/index.html" target="_blank">&#x6280;&#x5DE7;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/FAQ.html" target="_blank">&#x5E38;&#x89C1;&#x95EE;&#x9898;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/Troubleshooting.html" target="_blank">&#x6392;&#x9519;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/Glossary.html" target="_blank">&#x8BCD;&#x6C47;&#x8868;</a></li>
<li><a href="http://camsong.github.io/redux-in-chinese//docs/api/index.html" target="_blank">API &#x6587;&#x6863;</a></li>
</ul>
<h3 id="%E7%A4%BA%E4%BE%8B">&#x793A;&#x4F8B;</h3>
<ul>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#counter-vanilla" target="_blank">&#x539F;&#x751F; Counter</a> (<a href="https://github.com/rackt/redux/tree/master/examples/counter-vanilla" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#counter" target="_blank">Counter</a> (<a href="https://github.com/rackt/redux/tree/master/examples/counter" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#todos" target="_blank">Todos</a> (<a href="https://github.com/rackt/redux/tree/master/examples/todos" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#todos-with-undo" target="_blank">&#x53EF;&#x64A4;&#x9500;&#x7684; Todos</a> (<a href="https://github.com/rackt/redux/tree/master/examples/todos-with-undo" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#todomvc" target="_blank">TodoMVC</a> (<a href="https://github.com/rackt/redux/tree/master/examples/todomvc" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#shopping-cart" target="_blank">&#x8D2D;&#x7269;&#x8F66;</a> (<a href="https://github.com/rackt/redux/tree/master/examples/shopping-cart" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#tree-view" target="_blank">Tree View</a> (<a href="https://github.com/rackt/redux/tree/master/examples/tree-view" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#async" target="_blank">&#x5F02;&#x6B65;</a> (<a href="https://github.com/rackt/redux/tree/master/examples/async" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#universal" target="_blank">Universal</a> (<a href="https://github.com/rackt/redux/tree/master/examples/universal" target="_blank">source</a>)</li>
<li><a href="http://camsong.github.io/redux-in-chinese/docs/introduction/Examples.html#real-world" target="_blank">Real World</a> (<a href="https://github.com/rackt/redux/tree/master/examples/real-world" target="_blank">source</a>)</li>
</ul>
<p>&#x5982;&#x679C;&#x4F60;&#x662F; NPM &#x65B0;&#x624B;&#xFF0C;&#x521B;&#x5EFA;&#x548C;&#x8FD0;&#x884C;&#x4E00;&#x4E2A;&#x65B0;&#x7684;&#x9879;&#x76EE;&#x6709;&#x96BE;&#x5EA6;&#xFF0C;&#x6216;&#x8005;&#x4E0D;&#x77E5;&#x9053;&#x4E0A;&#x9762;&#x7684;&#x4EE3;&#x7801;&#x5E94;&#x8BE5;&#x653E;&#x5230;&#x54EA;&#x91CC;&#x4F7F;&#x7528;&#xFF0C;&#x8BF7;&#x4E0B;&#x8F7D; <a href="https://github.com/jackielii/simplest-redux-example" target="_blank">simplest-redux-example</a> &#x8FD9;&#x4E2A;&#x793A;&#x4F8B;&#xFF0C;&#x5B83;&#x662F;&#x4E00;&#x4E2A;&#x96C6;&#x6210;&#x4E86; React&#x3001;Browserify &#x548C; Redux &#x7684;&#x6700;&#x7B80;&#x5316;&#x7684;&#x793A;&#x4F8B;&#x9879;&#x76EE;&#x3002;</p>
<h3 id="%E4%BA%A4%E6%B5%81">&#x4EA4;&#x6D41;</h3>
<p>&#x6253;&#x5F00; Slack&#xFF0C;&#x52A0;&#x5165; <a href="http://reactiflux.com/" target="_blank">Reactiflux</a> &#x4E2D;&#x7684; <strong>#redux</strong> &#x9891;&#x9053;&#x3002;</p>
<h3 id="%E6%84%9F%E8%B0%A2">&#x611F;&#x8C22;</h3>
<ul>
<li><a href="https://github.com/evancz/elm-architecture-tutorial" target="_blank">Elm &#x67B6;&#x6784;</a> &#x4ECB;&#x7ECD;&#x4E86;&#x4F7F;&#x7528; reducers &#x6765;&#x64CD;&#x4F5C; state &#x6570;&#x636E;&#xFF1B;</li>
<li><a href="http://blog.confluent.io/2015/03/04/turning-the-database-inside-out-with-apache-samza/" target="_blank">Turning the database inside-out</a> &#x5927;&#x5F00;&#x8111;&#x6D1E;;</li>
<li><a href="http://www.youtube.com/watch?v=j-kj2qwJa_E" target="_blank">ClojureScript &#x91CC;&#x4F7F;&#x7528; Figwheel</a> for convincing me that re-evaluation should &#x201C;just work&#x201D;;</li>
<li><a href="https://github.com/webpack/docs/wiki/hot-module-replacement-with-webpack" target="_blank">Webpack</a> &#x70ED;&#x6A21;&#x5757;&#x66FF;&#x6362;;</li>
<li><a href="https://github.com/acdlite/flummox" target="_blank">Flummox</a> &#x6559;&#x6211;&#x5728; Flux &#x91CC;&#x53BB;&#x6389;&#x6837;&#x677F;&#x6587;&#x4EF6;&#x548C;&#x5355;&#x4F8B;&#x5BF9;&#x8C61;&#xFF1B;</li>
<li><a href="https://github.com/threepointone/disto" target="_blank">disto</a> &#x6F14;&#x793A;&#x4F7F;&#x7528;&#x70ED;&#x52A0;&#x8F7D; Stores &#x7684;&#x53EF;&#x884C;&#x6027;&#xFF1B;</li>
<li><a href="https://github.com/optimizely/nuclear-js" target="_blank">NuclearJS</a> &#x8BC1;&#x660E;&#x8FD9;&#x6837;&#x7684;&#x67B6;&#x6784;&#x6027;&#x80FD;&#x53EF;&#x4EE5;&#x5F88;&#x597D;&#xFF1B;</li>
<li><a href="https://github.com/omcljs/om" target="_blank">Om</a> &#x666E;&#x53CA; state &#x60DF;&#x4E00;&#x539F;&#x5B50;&#x5316;&#x7684;&#x601D;&#x60F3;&#x3002;</li>
<li><a href="https://github.com/staltz/cycle" target="_blank">Cycle</a> &#x4ECB;&#x7ECD;&#x4E86; function &#x662F;&#x5982;&#x4F55;&#x5728;&#x5F88;&#x591A;&#x573A;&#x666F;&#x90FD;&#x662F;&#x6700;&#x597D;&#x7684;&#x5DE5;&#x5177;&#xFF1B;</li>
<li><a href="https://github.com/facebook/react" target="_blank">React</a> &#x5B9E;&#x8DF5;&#x542F;&#x8FEA;&#x3002;</li>
</ul>
<h3 id="%E4%BD%9C%E8%80%85%E5%88%97%E8%A1%A8">&#x4F5C;&#x8005;&#x5217;&#x8868;</h3>
<blockquote>
<p>&#x5B9A;&#x671F;&#x66F4;&#x65B0;&#xFF0C;&#x8C22;&#x8C22;&#x5404;&#x4F4D;&#x8F9B;&#x52E4;&#x8D21;&#x732E;</p>
</blockquote>
<ul>
<li><a href="https://github.com/camsong" target="_blank">Cam Song &#x4F1A;&#x5F71;@camsong</a></li>
<li><a href="https://github.com/jovey-zheng" target="_blank">Jovey Zheng@jovey-zheng</a></li>
<li><a href="https://github.com/pandazki" target="_blank">Pandazki@pandazki</a></li>
<li><a href="https://github.com/rccoder" target="_blank">Shangbin Yang@rccoder</a></li>
<li><a href="https://github.com/dorayx" target="_blank">Doray Hong@dorayx</a></li>
<li><a href="https://github.com/yuweiw823" target="_blank">Yuwei Wang@yuweiw823</a></li>
<li><a href="https://github.com/hashtree" target="_blank">Yudong@hashtree</a></li>
<li><a href="https://github.com/arcthur" target="_blank">Arcthur@arcthur</a></li>
<li><a href="https://github.com/demohi" target="_blank">Desen Meng@demohi</a></li>
<li><a href="https://github.com/zhe" target="_blank">Zhe Zhang@zhe</a></li>
<li><a href="https://github.com/alcat2008" target="_blank">alcat2008</a></li>
<li><a href="https://github.com/Frozenme" target="_blank">Frozenme</a></li>
<li><a href="https://github.com/Yogi-Jiang" target="_blank">&#x59DC;&#x6768;&#x519B;@Yogi-Jiang</a></li>
<li><a href="https://github.com/happybai" target="_blank">Byron Bai@happybai</a></li>
<li><a href="https://github.com/guocheng" target="_blank">Guo Cheng@guocheng</a></li>
<li><a href="https://github.com/omytea" target="_blank">omytea</a></li>
<li><a href="https://github.com/namelos" target="_blank">Fred Wang</a></li>
<li><a href="https://github.com/amowu" target="_blank">Amo Wu</a></li>
<li><a href="https://github.com/chentsulin" target="_blank">C. T. Lin</a></li>
<li><a href="https://github.com/timqian" target="_blank">&#x94B1;&#x5229;&#x6C5F;</a></li>
<li><a href="https://github.com/sorrycc" target="_blank">&#x4E91;&#x8C26;</a></li>
<li><a href="https://github.com/denvey" target="_blank">denvey</a></li>
<li><a href="https://github.com/zousandian" target="_blank">&#x4E09;&#x70B9;</a></li>
<li><a href="https://github.com/ele828" target="_blank">Eric Wong</a></li>
<li><a href="https://github.com/owenyang0" target="_blank">Owen Yang</a></li>
<li><a href="https://github.com/Darmody" target="_blank">Cai Huanyu</a></li>
</ul>
<p><strong>&#x672C;&#x6587;&#x6863;&#x7FFB;&#x8BD1;&#x6D41;&#x7A0B;&#x7B26;&#x5408; <a href="https://github.com/react-guide/ETC" target="_blank">ETC &#x7FFB;&#x8BD1;&#x89C4;&#x8303;</a>&#xFF0C;&#x6B22;&#x8FCE;&#x4F60;&#x6765;&#x4E00;&#x8D77;&#x5B8C;&#x5584;</strong></p>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        
        <a href="./docs/introduction/index.html" class="navigation navigation-next navigation-unique" aria-label="Next page: 介绍"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="gitbook/app.js"></script>

    
    <script src="gitbook/plugins/gitbook-plugin-edit-link/plugin.js"></script>
    

    
    <script src="gitbook/plugins/gitbook-plugin-ga/plugin.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"fontSettings":{"theme":null,"family":"sans","size":2},"edit-link":{"base":"https://github.com/camsong/redux-in-chinese/tree/master","label":"开始纠错"},"ga":{"token":"UA-66122997-1"}};
    gitbook.start(config);
});
</script>

        <script>(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)})(window,document,'script','//www.google-analytics.com/analytics.js','ga');ga('create', 'UA-66122997-1', 'auto');ga('send', 'pageview');</script>
    </body>
    
</html>
